package com.lemonPiggy.message.service.impl;

import java.util.List;

import com.lemonPiggy.message.domain.MessageAnnouncement;
import com.lemonPiggy.message.mapper.MessageAnnouncementMapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.IdUtils;
import com.lemonPiggy.message.service.IMessageAnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 系统通告Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-08-17
 */
@Service
public class MessageAnnouncementServiceImpl implements IMessageAnnouncementService
{
    @Autowired
    private MessageAnnouncementMapper messageAnnouncementMapper;

    /**
     * 查询系统通告
     * 
     * @param id 系统通告ID
     * @return 系统通告
     */
    @Override
    public MessageAnnouncement selectMessageAnnouncementById(String id)
    {
        return messageAnnouncementMapper.selectMessageAnnouncementById(id);
    }

    /**
     * 查询系统通告列表
     * 
     * @param messageAnnouncement 系统通告
     * @return 系统通告
     */
    @Override
    public List<MessageAnnouncement> selectMessageAnnouncementList(MessageAnnouncement messageAnnouncement)
    {
        return messageAnnouncementMapper.selectMessageAnnouncementList(messageAnnouncement);
    }

    /**
     * 新增系统通告
     * 
     * @param messageAnnouncement 系统通告
     * @return 结果
     */
    @Override
    public int insertMessageAnnouncement(MessageAnnouncement messageAnnouncement)
    {
        messageAnnouncement.setId(IdUtils.simpleUUID());
        messageAnnouncement.setCreateTime(DateUtils.getNowDate());
        if(messageAnnouncement.getSendStatus()==null){
            messageAnnouncement.setSendStatus("0");
        }
        messageAnnouncement.setDelFlag("0");
        messageAnnouncement.setCreateBy(messageAnnouncement.getUpdateBy());
        return messageAnnouncementMapper.insertMessageAnnouncement(messageAnnouncement);
    }

    /**
     * 修改系统通告
     * 
     * @param messageAnnouncement 系统通告
     * @return 结果
     */
    @Override
    public int updateMessageAnnouncement(MessageAnnouncement messageAnnouncement)
    {
        messageAnnouncement.setUpdateTime(DateUtils.getNowDate());
        return messageAnnouncementMapper.updateMessageAnnouncement(messageAnnouncement);
    }

    /**
     * 批量删除系统通告
     * 
     * @param ids 需要删除的系统通告ID
     * @return 结果
     */
    @Override
    public int deleteMessageAnnouncementByIds(String[] ids)
    {
        return messageAnnouncementMapper.deleteMessageAnnouncementByIds(ids);
    }

    /**
     * 删除系统通告信息
     * 
     * @param id 系统通告ID
     * @return 结果
     */
    @Override
    public int deleteMessageAnnouncementById(String id)
    {
        return messageAnnouncementMapper.deleteMessageAnnouncementById(id);
    }

    @Override
    public List<MessageAnnouncement> querySysCementPageByUserId(Long userId, String msgCategory) {
        return messageAnnouncementMapper.querySysCementListByUserId(userId,msgCategory);
    }

    @Override
    public List<MessageAnnouncement> selectMessageAnnouncementListQuery(MessageAnnouncement messageAnnouncement,Long userId) {
        return messageAnnouncementMapper.selectMessageAnnouncementListQuery(userId, messageAnnouncement);
    }

    @Override
    public List<MessageAnnouncement> querySysCementPageByUserIdALL(Long userId, String msgCategory) {
        return messageAnnouncementMapper.querySysCementPageByUserIdALL(userId,msgCategory);
    }
}
